@extends('admin_system/public/layout')
@section('content')
    <div class="panel panel-default">
        <link rel="stylesheet" href="//g.alicdn.com/de/prismplayer/2.4.0/skins/default/aliplayer-min.css"/>
        <script src="https://g.alicdn.com/de/prismplayer/2.4.0/aliplayer-h5-min.js"></script>
        <div class="panel-heading">
            <h3 class="panel-title text-center">直播室: {{$data->live_title}}</h3>
        </div>
        <div class="panel-body">

            <div style="display: flex;justify-content: space-between">
                <div style="width: 30%;height: 300px;">
                    <div style="float: right;">
                        {!! $data->live_url ? QrCode::size(200)->generate($data->live_url):"" !!}
                    </div>
                    <div style="float: left;width: 50%">

                        <a href="/admin_system/live/open_live/{{$data->id}}/1"
                           style="text-decoration: none;display: block">
                            <button class="btn btn-danger" style="width: 80%;margin-top: 30px">开启直播1</button>
                        </a>
                        <a href="/admin_system/live/close_live/{{$data->id}}/2"
                           style="text-decoration: none;display: block">
                            <button class="btn btn-warming" style="width: 80%;margin-top: 30px">暂停直播2</button>
                        </a>
                        <a href="/admin_system/live/close_live/{{$data->id}}/3"
                           style="text-decoration: none;display: block">
                            <button class="btn btn-danger" style="width: 80%;margin-top: 30px">停止直播3</button>
                        </a>
                        <a href="/admin_system/live/close_live/{{$data->id}}/4"
                           style="text-decoration: none;display: block">
                            <button class="btn btn-info" style="width: 80%;margin-top: 30px">即将直播4</button>
                        </a>
                    </div>
                </div>
                <div style="width: 70%;height: 300px;">
                    <div style="margin-top: 20px">
                        @if($data->is_show==0)
                            <a href="/admin_system/live/show_live/{{$data->id}}/{{1}}"
                               style="text-decoration: none;display: block">
                                <button class="btn btn-danger" style="width: 20%;margin-top: 30px">显示直播</button>
                            </a>
                        @else
                            <a href="/admin_system/live/show_live/{{$data->id}}/{{0}}"
                               style="text-decoration: none;display: block">
                                <button class="btn btn-danger" style="width: 20%;margin-top: 30px">隐藏直播</button>
                            </a>
                        @endif

                        <a href="/admin_system/live/msg_view/{{implode('-',explode('#',$data->chat_group_id))}}"
                           style="text-decoration: none;display: block">
                            <button class="btn btn-danger" style="width: 20%;margin-top: 30px">主播消息管理</button>
                        </a>
                        <a href="/admin_system/live/view/{{$data->id}}"
                           style="text-decoration: none;display: block">
                            <button class="btn btn-danger" style="width: 20%;margin-top: 30px">在线人员管理</button>
                        </a>
                    </div>

                    <div style="margin-left: 50px;width: 40%">
                        <div class="prism-player" id="J_prismPlayer"
                             style="position: absolute;width: 40%;top: 65px;right: 113px"></div>
                    </div>
                </div>
            </div>

            {{--<div id="live_left_box"--}}
            {{--style="width: 100%;height:600px;display: flex;justify-content: space-between;border: 1px solid red">--}}
            {{--<div style="float: left;width: 30%;list-style: none;border-right: 1px solid red">--}}
            {{--<li style="width: 80%;cursor: pointer;margin-top: 20px;height: 30px;line-height:30px;border: 1px solid red;text-align: center">--}}
            {{--极光推送--}}
            {{--</li>--}}
            {{--<li style="width: 80%;cursor: pointer;margin-top: 20px;height: 30px;line-height:30px;border: 1px solid red;text-align: center">--}}
            {{--群通知--}}
            {{--</li>--}}
            {{--<li style="width: 80%;cursor: pointer;margin-top: 20px;height: 30px;line-height:30px;border: 1px solid red;text-align: center">--}}
            {{--群订阅--}}
            {{--</li>--}}
            {{--<li style="width: 80%;cursor: pointer;margin-top: 20px;height: 30px;line-height:30px;border: 1px solid red;text-align: center">--}}
            {{--在线管理--}}
            {{--</li>--}}
            {{--</div>--}}
            {{--<div style="float: left;width: 70%;height: 600px">--}}
            {{--<div></div>--}}
            {{--<div></div>--}}
            {{--<div></div>--}}
            {{--</div>--}}
            {{--</div>--}}


            <div class="form-group">
                <label for="inputID" class="control-label">直播室:</label>
                <div class="">
                    <input type="text" readonly name="name" id="inputID" class="form-control"
                           value="{{$data->live_title}}">
                </div>
            </div>


            <div class="form-group">
                <label for="inputID" class="control-label">封面:</label>
                <div class="">
                    <img src="/{{$data->face_img}}" alt="" width="250px">
                </div>
            </div>
            <hr>

            <div class="form-group">
                <label for="inputID" class="control-label">推送:</label>
                <div class="">
                    <textarea name="notice" id="notice"
                              style="width: 100%;height: 100px;">{{$data->push_msg}}</textarea>
                </div>
            </div>

            <div class="form-group">
                <form action="/admin_system/live/test">
                    <input type="hidden" name="id" value="{{$data->id}}">
                    <input type="hidden" name="no" id="no">
                    <button class="btn btn-danger" type="submit"> 发送推送信息</button>
                </form>
            </div>
            <hr>

            <div class="alert alert-info">
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                <strong>注意!</strong> 不要发送超过30个字...
            </div>
            <div class="form-group">
                <label for="inputID" class="control-label">修改群通知:</label>
                <div class="">
                    <textarea name="notice" id="ps" placeholder=不能超过80个汉字
                              style="width: 100%;height: 100px;">{{$data->notice}}</textarea>
                </div>
            </div>

            {{--<div class="alert alert-info">--}}
                {{--<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>--}}
                {{--<strong>注意！</strong> 0为一直显示通知,大于0的数字表示显示几秒--}}
            {{--</div>--}}
            {{--<div class="form-group">--}}
                {{--<input type="number" id="show_time" name="show_time" class="form-control" value=0>--}}
            {{--</div>--}}

            <div class="form-group">
                <label for="inputID" class="control-label">是否显示群公告:</label>
                <div class="">
                    <select name="show_time" id="show_time" class="form-control">
                        <option value="1" @if($data->is_notice==1) selected @endif>显示</option>
                        <option value="0" @if($data->is_notice==0) selected @endif>不显示</option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <form action="/admin_system/live/notf">
                    <input type="hidden" name="id" value="{{$data->id}}">
                    <input type="hidden" name="pusha" id="push">
                    <input type="hidden" name="sta" id="st" value="{{$data->is_notice}}">
                    <button class="btn btn-danger" type="submit">修改公告</button>
                </form>
            </div>
            <hr>


            <style>

                .form{
                    border:1px solid #666;
                    overflow: hidden;
                    display: block;
                    float: none;
                    margin-top:20px;
                }
            </style>


            <form class="form-horizontal col-md-6 form"  action="/admin_system/live/intr" id="link_url_form" method="post" enctype="multipart/form-data">
                {{csrf_field()}}
                <h4 ><strong>修改订阅:</strong></h4>
                <input type="hidden" name="id" value="{{$data->id}}">
                <input type="hidden" name="chat_group_id" value="{{$data->chat_group_id}}">

                <div class="form-group">
                    <label  class="col-sm-2 control-label">标题</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="ad_text" placeholder="介绍文字" value="{{$data->ad_text}}">
                    </div>
                </div>

                <div class="form-group">
                    <label  class="col-sm-2 control-label">图片</label>
                    <div class="col-sm-10">
                        <input type="file" id="dingyuefile" class="form-control" name="ad_img" style="width:200px;" onchange="show_upload_file('dingyuefile','dingyueimg')">
                        <img src="/{{$data->ad_img}}" alt="" width="200" style="padding: 10px" id="dingyueimg">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">链接地址</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" name="ad_link" placeholder="链接地址,如:/home/index" value="{{$data->ad_link}}">
                    </div>
                </div>

                <div class="form-group">
                    <label  class="col-sm-2 control-label">状态</label>
                    <div class="col-sm-3">
                        <select name="is_show_ad" class="form-control">
                            <option value="1" @if($data->is_show_ad==1) selected @endif>显示</option>
                            <option value="0" @if($data->is_show_ad==0) selected @endif>不显示</option>
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-danger">修改订阅</button>
                    </div>
                </div>
            </form>


            <form action="/admin_system/live/view_times" class="form-horizontal col-md-6 form" >

                {{csrf_field()}}
                <h4 ><strong>修改观看次数:</strong></h4>
                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-2 control-label">观看人数</label>
                    <div class="col-sm-5">
                        <input  readonly  class="form-control" value="{{$data->live_detail_view_times}}">
                    </div>
                </div>

                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-2 control-label">在线人数</label>
                    <div class="col-sm-5">
                        <input type="text" readonly id="inputID" class="form-control" value="{{$data->ali_live_view_times}}">
                    </div>
                </div>


                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-2 control-label">添加人数</label>
                    <div class="col-sm-5">
                        <input name="name" readonly  class="form-control" value="{{$data->add_view_times}}" required="required">
                    </div>
                </div>

                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-2 control-label">添加人数</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="viewed_times" value="0">
                    </div>
                </div>

                <input type="hidden" name="id" value="{{$data->id}}">
                <input type="hidden" name="chat_group_id" value="{{$data->chat_group_id}}">

                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button class="btn btn-danger" type="submit">修改群人数</button>
                        <button class="btn btn-danger" id="ref_page" type="button">刷新当前页面</button>
                    </div>
                </div>

            </form>


        </div>
    </div>
    <script>
        @if(session('push_live'))
        alert('{{session('push_live')}}')
        @endif

        //推送
        let notice = document.getElementById('notice');
        let no = document.getElementById('no');
        notice.addEventListener('input', function () {
            let data = this.value;
            no.value = data.replace(/(^\s)|(\s*$)/g, " ");
            console.log(data);
        })

        //通知
        let ps = document.getElementById('ps');
        let show_time = document.getElementById('show_time');
        let push = document.getElementById('push');
        let st = document.getElementById('st');
        ps.addEventListener('input', function () {
            let data = this.value;
            push.value = data.replace(/(^\s)|(\s*$)/g, " ");
            console.log(data);
        })

        show_time.addEventListener('change',function () {
            let index=show_time.selectedIndex;
            let show_val=show_time.options[index].value;
            let data = show_val;
            st.value = data;
        })

        //刷新当前页面
        var ref_page = document.getElementById('ref_page');
        ref_page.addEventListener('click', function () {
            window.location.reload(true);
        })

        var player = new Aliplayer({
            id: 'J_prismPlayer',
            width: '100%',
            autoplay: false,
            //支持播放地址播放,此播放优先级最高

            source: '{{$live_url}}',
            {{--source: "{{$live_url}}",--}}
        }, function (player) {
            console.log(player);
            console.log('{{$live_url}}')
        });

        //验证修改群订阅是否含有http|https协议
        // var link_url = document.getElementById('link_url');
        // var link_url_form = document.getElementById('link_url_form');
        // link_url_form.addEventListener('submit', function (e) {
        //     e.preventDefault();
        //     var reg = /(http|https)/;
        //     var url = link_url.value;
        //     if (reg.test(url) === false) {
        //         alert('群订阅的url地址必须是http或者是https协议');
        //         return false;
        //     }
        //     link_url_form.submit();
        // })

    </script>
@endsection
